package com.java并发编程.Fork_Join.RecursiveAction;

import java.util.concurrent.RecursiveAction;

/*
 * 注：RecursiveAction 执行任务，无返回值
 */
public class MyRecursiveAction1 extends RecursiveAction{
	
	private int begin;
	private int end;
	
	public MyRecursiveAction1(int begin, int end) {
		super();
		this.begin = begin;
		this.end = end;
	}



	@Override
	protected void compute() {
		
		System.out.println(Thread.currentThread().getName());
		
		if (end - begin > 2) {
			int mid = (end - begin)/2;
			MyRecursiveAction1 left = new MyRecursiveAction1(begin, mid);
			MyRecursiveAction1 right = new MyRecursiveAction1(mid+1, end);
			this.invokeAll(left,right);
		} else {
			System.out.println("组合为：" + begin+ "-" + end);
		}
		
	}

}
